package com.easy;

/**
 * Created by Lxk on 2019/6/16.
 */
public class Solution965 {

    private boolean isSingleValTree(int val , TreeNode root){
        if(root==null){
            return true;
        }
        if(root.val == val){
            boolean leftRes = isSingleValTree(val,root.left);
            boolean rightRes = isSingleValTree(val,root.right);
            return leftRes&&rightRes;
        }else{
            return false;
        }
    }

    public boolean isUnivalTree(TreeNode root) {
        if(root==null){
            return true;
        }
        return isSingleValTree(root.val ,root);
    }

}
